export const namespace = "stadiumPerformanceSet";
import { Space } from "antd";

export const calcColumns = (params) => {
  const { roles } = params;
  let rolesNames = {};
  roles.forEach((v) => {
    rolesNames[v.roleId] = v.roleName;
  });
  const columns = [
    {
      title: "ID",
      hidden: process.env.UMI_ENV == "prod" ? true : false,
      width: 180,
      dataIndex: "id",
      hideInSearch: true,
    },
    {
      title: "提成方案名称",
      dataIndex: "planName",
    },
    {
      title: "适用角色",
      dataIndex: "applyRoleIds",
      hideInSearch: true,
      render: (_, records) => {
        let name = _.split(",")
          .map((s) => {
            return rolesNames[s];
          })
          .join(",");
        return <Space>{name}</Space>;
      },
    },
    {
      title: "计算方式",
      dataIndex: "countMethod",
      hideInSearch: true,
      valueEnum: {
        1: { text: "阶梯提成" },
        2: { text: "阶段提成" },
      },
    },

    {
      title: "计算周期",
      dataIndex: "countCycle",
      hideInSearch: true,
      valueEnum: {
        1: { text: "月" },
        2: { text: "季" },
        3: { text: "年" },
      },
    },
    // {
    //   title: '更新人',
    //   dataIndex: 'updateBy',
    //   hideInSearch: true
    // },
    // {
    //   title: '更新时间',
    //   dataIndex: 'updateTime',
    //   hideInSearch: true
    // },
    {
      title: "状态",
      dataIndex: "status",
      valueEnum: {
        0: { text: "启用", status: "Success" },
        1: { text: "禁用", status: "Error" },
      },
    },
  ];
  if (params?.operate) {
    columns.push(params?.operate);
  }
  return columns;
};
